//
//  YSYuetandexiangmuViewController.m
//  YSZC
//
//  Created by 张斌 on 16/4/29.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "YSYuetandexiangmuViewController.h"

@interface YSYuetandexiangmuViewController ()
// 约谈的项目的模型数组
@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property(nonatomic,strong)NSMutableArray* projectmodels;
@end

@implementation YSYuetandexiangmuViewController
- (NSMutableArray *)projectmodels{
    if (_projectmodels == nil) {
        _projectmodels = [NSMutableArray array];
        [_projectmodels addObject:@"22"];
        [_projectmodels addObject:@"23"];
        [_projectmodels addObject:@"24"];
        [_projectmodels addObject:@"25"];
    }
    return _projectmodels;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    // 自动计算行高
    self.tableview.estimatedRowHeight = 400;
    self.tableview.rowHeight = UITableViewAutomaticDimension;
    // 设置tableView在编辑模式下可以多选，并且只需设置一次
    self.tableview.allowsMultipleSelectionDuringEditing = YES;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"编辑" style:UIBarButtonItemStylePlain target:self action:@selector(selectdelete)];

    
    
}

- (void)selectdelete{
    
    [self.tableview setEditing:!self.tableview.isEditing animated:YES];
}
- (IBAction)delete:(id)sender {
    [self removeSelectedCells];
}

//删除多行的方法
- (void)removeSelectedCells {
    NSMutableArray *deletearrs = [NSMutableArray array];
    for (NSIndexPath *indexPath in self.tableview.indexPathsForSelectedRows) {
        [deletearrs addObject:self.projectmodels[indexPath.row]];
    }
    
    [self.projectmodels removeObjectsInArray:deletearrs];
        [self.tableview reloadData];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.projectmodels.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YuetandexiangmuCell" forIndexPath:indexPath];
    
    return cell;
}

@end
